<form action="" method="get" accept-charset="utf-8">
<table class="form2c-search">

<?php if (isset($_GET['sortcol'])): ?>
	<input type="hidden" name="sortcol" value="<?php echo $_GET['sortcol'] ?>" id="sortcol" />
	<?php if (isset($_GET['sortdir'])): ?>
		<input type="hidden" name="sortdir" value="<?php echo $_GET['sortdir'] ?>" id="sortcol" />
	<?php endif ?>
<?php endif ?>

<?php foreach ($this->_model->conditionParam as $key => $row) { ?>
	<?php
		$class = array();
		if (isset($row['class'])) {
			if (is_array($row['class'])) {
				$class=$row['class'];
			} else {
				array_push($class,$row['class']);
			}
		}

	?>
	<tr >
		<th >
			<label for="<?php echo $key; ?>" ><?php echo $row['label'] ?></label>
		</th>
		<td >
			<?php if ($row['data']): ?>
				<select name="<?php echo $key?>" id="<?php echo $key?>" class="<?php echo implode($class,' ') ?>" >
					<?php foreach ($row['data'] as $okey => $ovalue): ?>
						<option 
							value="<?php echo $okey; ?>" 
							<?php echo (isset($_GET[$key])&& $_GET[$key]!=='' &&$_GET[$key]==$okey)? 'selected' : ''  ?>
						>
							<?php echo $ovalue; ?>
						</option>
					<?php endforeach ?>
				</select>
			<?php elseIf (isset($row['data2']) && $row['data2']): ?>
			<select name="<?php echo $key?>" id="<?php echo $key?>" class="<?php echo implode($class,' ') ?>" >
				<option value=""> - All <?php echo $row['label']?> -</option>
				<?php foreach ($row['data2']['data'] as $okey => $ovalue): ?>
					<option 
						value="<?php echo $okey; ?>" 
						<?php foreach ($row['data2']['attr'] as $attr): ?>
							<?php echo $attr ?>="<?php echo $ovalue[$attr] ?>"
						<?php endforeach ?>
						<?php echo (isset($_GET[$key])&& $_GET[$key]!=='' &&$_GET[$key]==$okey)? 'selected' : ''  ?>
					>
						<?php echo $ovalue[$row['data2']['inner']]; ?>
					</option>
				<?php endforeach ?>
			</select>
			<?php else : ?>
				<input 
					type="text" 
					name="<?php echo $key; ?>" 
					class="<?php echo implode($class,' ') ?>" 
					value="<?php echo (isset($_GET[$key]))? CHtml::encode($_GET[$key]) : ''  ?>" 
					id="<?php echo $key; ?>" 
				/>
			<?php endif ?>
		</td>
	</tr>
<?php } ?>
	<tfoot >
		<tr >
			<th >
			</th>
			<td style='padding-top:12px'>
				<button class='bt2'> Search </button>
				<button class='bt1 reset' href='<?php echo Yii::app()->request->baseUrl ?>/<?php echo Yii::app()->controller->uniqueId.'/'.
								  Yii::app()->controller->action->id; ?>' > Reset </button>
			</td>
		</tr>
	</tfoot>
</table>
</form>
<div class='clear' style='height:10px;'></div>